//
//  MovieDetailViewController.m
//  DaHaiDouBan
//
//  Created by dllo on 15/10/31.
//  Copyright © 2015年 Wang Dahai. All rights reserved.
//

#import "MovieDetailViewController.h"
#import "AppTool.h"
#import "MovieDetail.h"
#import "MBProgressHUD.h"
@interface MovieDetailViewController ()

@property (nonatomic, retain) MBProgressHUD *hud;

@end

@implementation MovieDetailViewController
- (void)dealloc
{
    [_movieDetailView release];
    [_hud release];
    [super dealloc];
}
- (void)viewDidLoad {
    [super viewDidLoad];

    self.view.backgroundColor = [UIColor lightGrayColor];

    self.scrollView = [[UIScrollView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    
    [self.view addSubview:self.scrollView];
    
    self.scrollView.contentSize = CGSizeMake(375, 800);
    
    
    
    self.movieDetailView = [[MovieDetailView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

    [self.scrollView addSubview:self.movieDetailView];
    
    [_movieDetailView release];
    
    
    NSString *urlStr = [NSString stringWithFormat:@"http://project.lanou3g.com/teacher/yihuiyun/lanouproject/searchmovie.php?movieId=%@",self.movieID];
    //小菊动起来
    self.hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    [self.hud show:YES];
    self.hud.labelText = @"小菊加载中......";
    [AppTool getDataWithAFNFromURL:urlStr andBlock:^(id result) {
        
        NSMutableDictionary *dic = result;
        
        NSLog(@"resukt = %@",result);
        
        NSMutableDictionary *resultDic = [dic objectForKey:@"result"];
        
        MovieDetail *movieDetail = [[MovieDetail alloc] init];
        
        [movieDetail setValuesForKeysWithDictionary:resultDic];
        
        
        self.movieDetailView.movieDetai = movieDetail;

        [movieDetail release];
        //小菊要休息
        [self.hud hide:YES];

    }];
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
